home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
ibm
/
loadall.arc
/
LOADALL.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-07-10
|
18KB
|
597 lines
'***************************************************************************
'*************** ***************
'*************** LOADALL.BAS ***************
'*************** ***************
'***************************************************************************
'
'
'
DEFINT A-Z
REM $DYNAMIC
DIM PflHighlight(12), PflLin$(12), PflMssg$(12)
DIM WindMem(2000) ' Window manager memory
DIM PfbHighlight(12), PfbLin$(12) ' Arrays for subprogram
DIM HelpLevel(12)
CLS
GOSUB DoMhtbInit
Dtaseg = VARSEG(WindMem(0)) ' Our reserved memory segment
IF Dtaseg = 0 THEN
CLS
BEEP
PRINT "You did not compute Dtaseg% correctly."
PRINT "Please look at the top of this program."
END
END IF
IF Monitor = &HB800 THEN ' If color monitor
BoxColr = 30 ' Yellow on blue
FillColr = 23 ' White on blue
HighColr = 28 ' Red on blue
InverseColr = 121 ' Blue
ELSE ' Mono monitor
BoxColr = 7 ' White on black
FillColr = 7 ' Ditto
HighColr = 31 ' Underlined high intensity white
InverseColr = 112 ' Black on white
END IF
GOTO PickPart
'***********************************************
'*
'* this is the put information on top line to pick from (lotus)
'*
'*******************************************
PickMainOption:
CLS
RESTORE Pick123Data
READ PflHighlight(0) ' Number of elements
FOR N = 1 TO PflHighlight(0)
READ PflLin$(N), PflHighlight(N), PflMssg$(N)
NEXT
PickLin = 3
LeftColumn = 1
RightColumn = 80
SelectionNumber = 1 ' Which one to start at
DisplayMessages = 1 ' Turn on message display
TerminatorChars$ = "TPL" + CHR$(27)' Highlight letter of each
' selection plus Esc
LOCATE 1, 1
PRINT "Please highlight your selection and ";
PRINT "press <Enter> or type in your selection";
LOCATE 2, 1
PRINT "Your selection: ";
LOCATE 21, 1
PRINT "Part Selected "; ShowPartType$
InputLin = 2
InputColumn = POS(0) ' current cursor position
GOSUB Display123
GOSUB DoPick123
LOCATE 10, 1
IF Kascii = 27 THEN
PRINT "You pressed 'Esc'"
GOTO ThatsAll
END
END IF
IF SelectionNumber THEN
PRINT "You chose ";
PRINT PflLin$(SelectionNumber)
ELSE
PRINT "You entered "; PflLin$(0)
END IF
IF SelectionNumber = 1 THEN GOTO TestConnection
IF SelectionNumber = 2 THEN GOTO PickPart
IF SelectionNumber = 3 THEN GOTO ProgBootLoader
'*********************** end routine *********************
'****************************
'*
'* this is where pick part no. from a box
'*
'****************************
PickPart:
LOCATE 2, 25
PRINT "Select the part desired"
Box = 2 ' Double line box
RESTORE PartBoxData
READ PfbHighlight(0) ' Number of elements
FOR N = 1 TO PfbHighlight(0)
READ PfbLin$(N), PfbHighlight(N)
NEXT
TopRow = 10 ' Boundaries of the box
LeftColumn = 1
BottomRow = 14
RightColumn = 40
SelectionNumber = 1 ' Which one to start at
TerminatorChars$ = "1AE9D" + CHR$(27)' Highlight letter of each
' part plus Esc
GOSUB PartBoxDisplay
GOSUB DoPickFromBox
LOCATE 20, 1
IF Kascii = 27 THEN
PRINT "You pressed 'Esc'"
GOTO ThatsAll
ELSE
PRINT "You chose selection number";
PRINT SelectionNumber, PfbLin$(SelectionNumber)
END IF
ShowPartType$ = PfbLin$(SelectionNumber)
IF SelectionNumber = 1 THEN
PartType$ = "A1": ZeroFill = 256: ProgLen = 0
MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
ProgPromFile$ = "PROGE9.MX"
END IF
IF SelectionNumber = 2 THEN
PartType$ = "A2": ZeroFill = 256: ProgLen = 0
MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
ProgPromFile$ = "PROGE2.MX"
END IF
IF SelectionNumber = 3 THEN
PartType$ = "E2": ZeroFill = 256: ProgLen = 0
MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
ProgPromFile$ = "PROGE2.MX"
END IF
IF SelectionNumber = 4 THEN
PartType$ = "E9": ZeroFill = 1000: ProgLen = 0
MSBBootAddress$ = "BF": LSBBootAddress$ = "40"
ProgPromFile$ = "PROGE9.MX"
END IF
IF SelectionNumber = 5 THEN
PartType$ = "D3": ZeroFill = 1000: ProgLen = 0
MSBBootAddress$ = "BF": LSBBootAddress$ = "46"
ProgPromFile$ = "PROGD3.MX"
END IF
GOTO PickMainOption
'***************** end routine ******************************
'******************************************************************
'*
'* this routine test the connection to selected part.
'*
'****************************************
TestConnection:
' CLS
BytesSent = 0
LOCATE 11, 1
PRINT "Verifying connection to HC11"
LOCATE 13, 1
PRINT " Please Wait"
TESTxCONTROL:
OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
Value = 255
PRINT #1, CHR$(Value);
IF ProgLen = 1 THEN
TransHexValue$ = "00": TransErrorCode = 0
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Connection (address step 1) failed."
GOTO ThatsAll
END IF
' IF TransErrorCode = 1 THEN PRINT "Connection step 1 (JMP) completed."
TransHexValue$ = "03": TransErrorCode = 0
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Connection (address step 2) failed."
GOTO ThatsAll
END IF
' IF TransErrorCode = 1 THEN PRINT "Connection step 2 (BF) completed."
END IF
TransHexValue$ = "7E": TransErrorCode = 0
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Connection step 1 (JMP) failed."
GOTO ThatsAll
END IF
' IF TransErrorCode = 1 THEN PRINT "Connection step 1 (JMP) completed."
TransHexValue$ = MSBBootAddress$: TransErrorCode = 0
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Connection step 2 "; MSBBootAddress$; " failed."
GOTO ThatsAll
END IF
' IF TransErrorCode = 1 THEN PRINT "Connection step 2 (BF) completed."
TransHexValue$ = LSBBootAddress$: TransErrorCode = 0
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Connection step 3 "; LSBBootAddress$; " failed."
GOTO ThatsAll
END IF
' IF TransErrorCode = 1 THEN PRINT "Connection step 3 (40) completed."
GOSUB FillZeros
CLOSE #1
LOCATE 15, 1
PRINT "The HC11 is responding correctly."
INPUT "Hit Enter to continue "; CR$
' CLS
GOTO PickMainOption
'************************ end routine ********************************
'***********************************************************************
'*
'* program ram to program e2 eeprom
'*
'************************************************************
ProgBootLoader:
LOCATE 11, 1
PRINT "Preparing HC11"
FileName$ = ProgPromFile$
BootLoad = 1
GOTO CheckFile
ProgProm:
' LOCATE 11, 1
' PRINT "Programming HC11"
FirstRecordSent = 0
BootLoad = 0
LOCATE 13, 1
PRINT " "
PRINT " "
PRINT " "
LOCATE 12, 1
INPUT "Enter file to be downloaded into PROM"; FileName$
CheckFile:
RecordCount = 0
OPEN FileName$ FOR INPUT AS #2
NoS1Records:
INPUT #2, record$
IF LEFT$(record$, 2) = "S0" THEN GOTO NoS1Records
IF LEFT$(record$, 2) = "S1" THEN
RecordCount = RecordCount + 1
GOTO NoS1Records
END IF
IF LEFT$(record$, 2) = "S9" THEN
IF RecordCount = 0 THEN
LOCATE 12, 1
PRINT "There are no S1 records in this file."
INPUT "Hit enter to continue"; CR$
GOTO PickMainOption
ELSE
GOTO SendFile
END IF
END IF
LOCATE 12, 1
PRINT "This file contains one or more none S19 records."
INPUT "Hit enter to continue"; CR$
GOTO PickMainOption
SendFile:
CLOSE #2
LOCATE 13, 1
PRINT "File contains "; RecordCount; " S1 records."
OPEN FileName$ FOR INPUT AS #2
IF BootLoad = 1 THEN
OPEN "COM2:1200,N,8,1,CS,DS,CD" FOR RANDOM AS #1
Value = 255
PRINT #1, CHR$(Value);
END IF
IF BootLoad = 0 THEN
OPEN "COM2:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
END IF
BytesSent = 0
GetRecord:
INPUT #2, record$
RecordType$ = LEFT$(record$, 2)
IF RecordType$ = "S0" THEN
' LOCATE 14, 1
' PRINT "Not transfering following S0 record."
' PRINT record$
GOTO GetRecord
END IF
IF RecordType$ = "S1" THEN
LOCATE 14, 1
PRINT "Transfering following S1 record."
PRINT record$
RecordLength$ = MID$(record$, 3, 2)
' PRINT "Record Length "; RecordLength$
RecordAddress$ = MID$(record$, 5, 4)
' PRINT "Record Address "; RecordAddress$
record$ = RIGHT$(record$, LEN(record$) - 8)
' PRINT "Data and Checksum "; record$
' INPUT "Hit RETURN to continue "; CR$
SendFileLength:
IF FirstRecordSent = 1 THEN GOTO ParseAndSend
IF BootLoad = 0 THEN
TransErrorCode = 0
Value = RecordCount
GOSUB TRANSxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Verification of file length failed."
GOTO ThatsAll
ELSE
' PRINT "File length sent successfully."
' INPUT "Hit enter to continue"; CR$
END IF
END IF
ParseAndSend:
IF BootLoad = 1 THEN
TransErrorCode = 0
IF LEN(record$) > 2 THEN
TransHexValue$ = LEFT$(record$, 2)
record$ = RIGHT$(record$, LEN(record$) - 2)
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Verification failed."
PRINT "Successfully sent "; BytesSent - 1; " bytes."
GOTO ThatsAll
ELSE
' PRINT ""; BytesSent; " bytes successfully sent."
GOTO ParseAndSend
END IF
ELSE
GOTO GetRecord
END IF
ELSE
SendAddress:
TransErrorCode = 0
TransHexValue$ = LEFT$(RecordAddress$, 2)
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Verification of MSB of address failed."
GOTO ThatsAll
ELSE
' PRINT "MSB of address sent successfully."
' INPUT "Hit enter to continue"; CR$
END IF
TransHexValue$ = RIGHT$(RecordAddress$, 2)
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Verification of LSB of address failed."
GOTO ThatsAll
ELSE
' PRINT "LSB of address sent successfully."
' INPUT "Hit enter to continue"; CR$
END IF
SendRecordLength:
TransHexValue$ = RecordLength$
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Verification of record length failed."
GOTO ThatsAll
ELSE
' PRINT "Record length sent successfully."
' INPUT "Hit enter to continue"; CR$
END IF
SendData:
IF LEN(record$) > 2 THEN
TransHexValue$ = LEFT$(record$, 2)
record$ = RIGHT$(record$, LEN(record$) - 2)
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Verification failed."
PRINT "Successfully sent "; BytesSent - 1; " bytes."
GOTO ThatsAll
ELSE
' PRINT ""; BytesSent; " bytes successfully sent."
GOTO SendData
END IF
ELSE
FirstRecordSent = 1
GOTO GetRecord
END IF
END IF
END IF
IF RecordType$ = "S9" THEN
IF BootLoad = 1 THEN
GOSUB FillZeros
CLOSE #1
CLOSE #2
BootLoad = 0
LOCATE 11, 1
PRINT "RAM ready to program PROM."
' INPUT "Hit enter to continue "; CR$
GOTO ProgProm
ELSE
' transfer starting address see HC11EVM manual pA2 S9 records.
CLS
PRINT "PROM has been programmed and should be running program."
PRINT "To continue using this program the HC11 must be reset."
INPUT "Would you like to continue with this program"; CR$
IF CR$ = "Y" OR CR$ = "y" THEN
CLOSE
GOTO PickMainOption
END IF
PRINT
PRINT "GOODBYE"
GOTO WhatNext
END IF
ELSE
PRINT "A Non S19 record has been encountered. Abort Download."
GOTO ThatsAll
END IF
WhatNext:
' download finished. what now?
ThatsAll:
CLOSE
END
'*******************************************************************************
'*****************************************************************************
'*
'* SUBROUTINES
'*
'*****************************************************************************
'*****************************************************************************
'*******************************************************************************
'*
'* This routine fills RAM with 0's for bootstrap.
'*
'*
'*******************************************************************************
FillZeros:
TransHexValue$ = "00": TransErrorCode = 0
IF ZeroFill = 1000 THEN GOTO FillDone
IF ZeroFill - BytesSent = 0 THEN GOTO FillDone
IF ZeroFill - BytesSent < 0 THEN PRINT "OverFilled RAM during Bootstrap load."
FOR I = BytesSent + 1 TO ZeroFill - 1
GOSUB SENDxVALUE
IF TransErrorCode <> 1 THEN
PRINT "Connection step "; I; " (00) failed. Step "; I
GOTO ThatsAll
END IF
'IF TransErrorCode = 1 THEN
' PRINT "Connection step "; I; " (00) completed."
'END IF
NEXT I
Value = 0
PRINT #1, CHR$(Value);
'PRINT "Connection step 256 sent and assumed completed."
FillDone:
RETURN
'*******************************************************************************
'*
'*
'* Call into this routine with parameter TransHexValue = string of two
'* characters constsiting of the byte in hex to be sent
'* Routine also increments BytesSent
'*
'*******************************************************************************
SENDxVALUE:
TESTxCOUNT = 1
FirstByteLoop = 0
ConvertValue:
Nibble$ = LEFT$(TransHexValue$, 1)
GOSUB NibbleConvert
MSBNibble = Nibble * 16
Nibble$ = RIGHT$(TransHexValue$, 1)
GOSUB NibbleConvert
Value = MSBNibble + Nibble
TRANSxVALUE:
PRINT #1, CHR$(Value);
TESTxLOOP1:
IF NOT EOF(1) THEN
INP$ = INPUT$(LOC(1), #1)
VAL1 = ASC(INP$)
IF VAL1 = Value THEN
' PRINT "Value Recieved Correctly"
TransErrorCode = 1
BytesSent = BytesSent + 1
GOTO TESTxDONE
ELSE
IF BytesSent = 0 AND FirstByteLoop = 0 THEN
FirstByteLoop = 1
GOTO TESTxLOOP1
END IF
PRINT "Value Returned Wrong"
PRINT "Value Sent = "; Value
PRINT "Value Received from HC11 ="; VAL1
INPUT "Hit Return to End"; CR$
TransErrorCode = 0
GOTO TESTxDONE
END IF
ELSE
TESTxCOUNT = TESTxCOUNT + 1
IF TESTxCOUNT > 10000 THEN
PRINT "HC11 NOT RESPONDING TO VALUE"
GOTO TESTxDONE
ELSE
GOTO TESTxLOOP1
END IF
END IF
TESTxDONE:
RETURN
'*******************************************************************************
'*
'*
'* Converts A to 10, B to 11 etc.
'*
'*
'****************************************************
NibbleConvert:
Nibble = VAL(Nibble$)
IF Nibble$ = "A" THEN Nibble = 10
IF Nibble$ = "B" THEN Nibble = 11
IF Nibble$ = "C" THEN Nibble = 12
IF Nibble$ = "D" THEN Nibble = 13
IF Nibble$ = "E" THEN Nibble = 14
IF Nibble$ = "F" THEN Nibble = 15
RETURN
'*******************************************************************************
'*
'* include files for display routines.
'*
'*
'***********************
REM $INCLUDE: 'MhtbInit.cal'
REM $INCLUDE: 'Pick123.cal'
REM $INCLUDE: 'Pickbox.cal'
'*******************************************************************************
'*
'* information for pick from top line (lotus) routines
'*
'*
'***********************
Pick123Data: ' Each choice has a number indicating which character
' should be highlighted for the selection. Note that
' since we have two fruits beginning with "P", we
' used "s" as the highlight character for "Pears".
' The message accompanying the selection follows
' the number indicating the highlight letter.
DATA 3
DATA Test, 1,Verify connection to selected part.
DATA Pick, 1,Choose target part.
DATA Load, 1,Load/Program selected part.
Display123:
LOCATE 22, 1
PRINT "Use the right/left/up/down/PgUp/PgDn keys to select"
PRINT "an item and then press <Enter>. Press 'Esc' to cancel."
RETURN
'*******************************************************************************
'*
'* information for pick from part selection box routines
'*
'*
'********************
PartBoxData:
DATA 5
DATA MC68HC11A1,10
DATA MC68HC811A2,10
DATA MC68HC811E2,10
DATA MC68HC711E9,11
DATA MC68HC711D3,10
PartBoxDisplay:
LOCATE 22, 1
PRINT "Use the right/left/up/down/PgUp/PgDn keys to select"
PRINT "an item and then press <Enter>. Press 'Esc' to cancel."
RETURN
END
'
'
'
'
'
'***************************************************************************
'*************** ***************
'*************** END ROUTINE ***************
'*************** ***************
'***************************************************************************